package com.nepxion.discovery.common.springcloudconfig.operation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;

public class SCConfigOperation {
	
	@Autowired
	private Environment environment;
	
    public String getConfig(String group, String serviceId) {
    	return environment.getProperty(group + "-" + serviceId);
    }

    public boolean removeConfig(String group, String serviceId) {
		return true; // 发布方使用,暂不支持
    }

    public boolean publishConfig(String group, String serviceId, String config) {
    	return true; // 发布方使用,暂不支持
    }

    public void subscribeConfig(String group, String serviceId, SCConfigSubscribeCallback subscribeCallback) {
        subscribeCallback.callback(getConfig(group, serviceId));
    }

}